using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.UserContrl
{
	public class VideoProgressBar : ProgressBar
	{
		private Button CancelBtn;
		public static DependencyProperty ProWidthProperty = DependencyProperty.Register("ProWidth", typeof(double), typeof(VideoProgressBar), new PropertyMetadata(0.0, null));
		public static DependencyProperty ProVisibilityProperty = DependencyProperty.Register("ProVisibility", typeof(Visibility), typeof(VideoProgressBar), new PropertyMetadata(0, null));
		public static DependencyProperty CancelBtnVisibilityProperty = DependencyProperty.Register("CancelBtnVisibility", typeof(Visibility), typeof(VideoProgressBar), new PropertyMetadata(0, null));
		private bool _contentLoaded;
		public event RoutedEventHandler OnCancelClick;
		public double ProWidth
		{
			get
			{
				return (double)base.GetValue(VideoProgressBar.ProWidthProperty);
			}
			set
			{
				base.SetValue(VideoProgressBar.ProWidthProperty, value);
			}
		}
		public Visibility ProVisibility
		{
			get
			{
				return (Visibility)base.GetValue(VideoProgressBar.ProVisibilityProperty);
			}
			set
			{
				base.SetValue(VideoProgressBar.ProVisibilityProperty, value);
			}
		}
		public Visibility CancelBtnVisibility
		{
			get
			{
				return (Visibility)base.GetValue(VideoProgressBar.CancelBtnVisibilityProperty);
			}
			set
			{
				base.SetValue(VideoProgressBar.CancelBtnVisibilityProperty, value);
			}
		}
		public VideoProgressBar()
		{
			this.InitializeComponent();
		}
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			this.CancelBtn = (base.GetTemplateChild("CancelBtn") as Button);
			this.CancelBtn.add_Click(new RoutedEventHandler(this.CancelBtn_Click));
			base.add_ValueChanged(new RoutedPropertyChangedEventHandler<double>(this.ImageProgressBar_ValueChanged));
			base.add_SizeChanged(new SizeChangedEventHandler(this.ImageProgressBar_SizeChanged));
		}
		private void CancelBtn_Click(object sender, RoutedEventArgs e)
		{
			if (this.OnCancelClick != null)
			{
				this.OnCancelClick.Invoke(sender, e);
			}
		}
		private void ImageProgressBar_SizeChanged(object sender, SizeChangedEventArgs e)
		{
			this.UpdateClip();
		}
		private void ImageProgressBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
		{
			this.UpdateClip();
		}
		private void UpdateClip()
		{
			if (base.get_Value() < base.get_Maximum())
			{
				this.CancelBtnVisibility = 0;
			}
			else
			{
				this.CancelBtnVisibility = 1;
			}
			double num = (base.get_ActualWidth() - 6.0 - 7.0 - 25.0) * ((base.get_Value() - base.get_Minimum()) / (base.get_Maximum() - base.get_Minimum()));
			if (num < 0.0)
			{
				num = 0.0;
			}
			this.ProWidth = num;
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Chat/Video/VideoProgressBar.xaml", 2));
		}
	}
}
